-
Notifications
You must be signed in to change notification settings - Fork 5.9k
fix(login): rate limiter shouldn't count successful logins #3141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ratelimiter needs adjustment - see individual review comments.
0d5f223
to
fc85bf1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits; looking in good shape otherwise!
Before, we weren't checking if a login was successful before counting it against the rate limiter. With this change, we only count unsuccessful logins against the rate limiter. We did this because this was a bug but also because it caused problems with our e2e tests hitting the rate limit.
This changes adds a new method called `.canTry` to the rate limiter to check if there are tokens remaining in the bucket. It also adds suggestions from @oxy to make sure the user can brute force past the rate limiter.
fc85bf1
to
7928dc2
Compare
d23c37c
to
f80d5c3
Compare
I've made the requested changed and Asher has approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good!
This PR fixes the login rate limiter to not count successful logins. This is important because it was causing issues with the e2e tests hitting the rate limit even though the logins were successful.
Changes
RateLimiter
loginPage.test.ts
intologin.test.ts
RateLimiter.canTry()
to check remaining tokensFixes #2647